part of 'widgets.dart';

/// 展示变化的一个列表，会自动将提出者高亮
class VersionList extends StatelessWidget {
  final String title;
  final RxList<Change> changes;
  const VersionList(this.title, this.changes, {super.key});

  @override
  Widget build(BuildContext context) {
    List<Widget> paragraphs = [];

    paragraphs.add(Text("## $title\n"));
    paragraphs.add(Space(height: 7));

    for (int i = 0; i < changes.length; i++) {
      /// 将Change转化为markdown格式的文字，然后直接用Article渲染
      String md = "";
      final change = changes[i];

      md += "${i + 1}. "; // 首先加入数字序号
      md += change.content; // 加入修改内容
      // 如果有建议者，将他们高亮加入
      if (change.proposer != null) {
        md += "**（by：${changes[i].proposer}）**";
      }

      paragraphs.add(Text(md));
    }

    return Padding(
      padding: EdgeInsets.only(bottom: 20),
      child: Column(children: paragraphs),
    );
  }
}
